package com.aerospace.serviceprovider.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class TcpClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",8886);
        OutputStream out = socket.getOutputStream();
        out.write("hello tcp server".getBytes());
        InputStream in = socket.getInputStream();
        byte b[] = new byte[1024];
        int len = in.read(b);
        System.out.println("接收到服务器消息："+new String(b,0,len));
        out.write("返回的数据已经收到".getBytes());
        socket.close();
    }
}
